<template>
	<view scroll-with-animation scroll-y style="height:100vh;position: relative;background-color: #FFFFFF;">
		<view class="list pl25 pr25" style="text-align: center;background-color: #FFFFFF;padding-top: 10rpx;" v-if="medicalrecordList&&medicalrecordList.length>0">
			<view class="jiuz-card" v-for=" (medicalrecordItem, medicalrecordIdx) in medicalrecordList" :key="medicalrecordItem.id" @click="tojiuzxq(medicalrecordIdx)">
				<view class="jiuz-card-head" style="border-bottom: 2rpx solid #D5D5D5;padding-bottom: 20rpx;margin-bottom: 20rpx;">
					<!-- <text style="color: #252ff4;" @click="returnAdvisoryvideo(medicalrecordIdx)" v-if="medDocInfoId && medDocInfoId != 0 ">选择</text> -->
					<radio :value="medicalrecordIdx" :checked="medicalrecordIdx == selId" style="transform:scale(0.8);color: #2A82E4;" color="#2A82E4" v-if="medDocInfoId && medDocInfoId != 0 " @click.stop="returnAdvisoryvideo(medicalrecordIdx)"/>
					<view style="width: 1rpx;height: 1rpx;" v-else></view>
					<text style="color: #424C4C;">查看详情</text>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">就诊时间：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">{{medicalrecordItem.updatedate}}</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">流水号：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">{{medicalrecordItem.medcalRecordId}}</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">主述：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">{{medicalrecordItem.cheifcomplaint}}</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">现病史：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">
						{{medicalrecordItem.historypresentillness}}
					</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">诊断：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">
						{{medicalrecordItem.outpatientdiagnosis?medicalrecordItem.outpatientdiagnosis:'--'}}
					</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">诊治经过：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">
						{{medicalrecordItem.diagnosistreatment}}
					</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">就诊科室：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">{{medicalrecordItem.treatDeptName}}</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">就诊医生：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">{{medicalrecordItem.attendingphysician}}</view>
				</view>
				<view class="jiuz-card-row">
					<view style="width: 140rpx;text-align: right;font-weight: bold;">诊疗意见：</view>
					<view style="color: #989898;width: calc( 100% - 140rpx);text-align: left;">{{medicalrecordItem.orderinfo}}</view>
				</view>
				<!-- <view class="jiuz-card-head" style="border-top: 2rpx solid #D5D5D5;padding-top: 20rpx;margin-bottom: 20rpx;">
					<view style="width: 27rpx;height: 27rpx;border: 2rpx solid #666666;border-radius: 50%;"></view>
				</view> -->
			</view>
			<uni-load-more :status="message" :contentText="contentText" @clickLoadMore="loadMore"></uni-load-more>
		</view>
		<view class="empty-list" v-else>
			<image style="height: 280rpx;" mode="heightFix" src="../../static/images/null.png"></image>
			<view style="color: #A7ADAD;margin-top: 20rpx;margin-bottom: 20rpx;">尚未查询到您的信息</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				wx: "https://app.mzmzb.com",
				selId: undefined,
				current: 1,
				hasNextPage: true, //是否有下一页
				message: 'more',
				medicalrecordList: [],
				contentText: {
					contentdown: "点击显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				userId:undefined,
				personalFileId:undefined,
				medDocInfoId:undefined,
				openids:''
			};
		},
		onLoad(option) {
			this.openids=uni.getStorageSync('openId')
			this.userId = option.userId
			this.personalFileId = option.personalFileId;
			this.medDocInfoId = option.medDocInfoId;
			this.getMedicalrecordInfo();
		},
		methods: {
			tojiuzxq(val){
				let obj = this.medicalrecordList[val]
				// console.log('val====',val)
				// console.log('obj====',obj)
				uni.setStorageSync("medicalrecord", obj)
				uni.navigateTo({
				    url: '/pages2/jiuzxq/index'
				});
			},
			//返回视频咨询或者图文咨询页面
			returnAdvisoryvideo(val) {
				let obj = this.medicalrecordList[val]
				if (obj.medcalRecordId == null) {
					obj.medcalRecordId = 0
				}
				this.selId = val
				uni.setStorageSync("medcalRecordId", obj.medcalRecordId)
				let pages = getCurrentPages();
				let prevPage = pages[pages.length-2]
				prevPage.$vm.medcalRecords = obj.medcalRecordId
				uni.navigateBack({
					delta:1
				})
			},
			getMedicalrecordInfo() {
				let usrUserId=uni.getStorageSync('usrUserId')
				var that = this;
				let data={
					personalFileId: this.personalFileId,
					current: this.current
				}
				that.func.$request('regulator/queryMedicalRecordList.tz',data,'GET').then(res=>{
					if (res.data.success) {
						if(this.medicalrecordList.length>0){
							let list = JSON.parse(JSON.stringify(res.data.result.list))
							this.medicalrecordList.push(...list)
						}else{
							this.medicalrecordList = JSON.parse(JSON.stringify(res.data.result.list));
						}
						if (res.data.result.hasNextPage) {
							this.message = 'more';
						} else {
							this.message = 'noMore';
						}
					} else {
						uni.showToast({
							title: '查询失败'
						})
					}
				})
			},
			//加载更多
			loadMore(e) {
				if (e.detail.status == 'more') {
					this.message = 'loading';
					this.current = this.current + 1;
					setTimeout(() => {
						this.getMedicalrecordInfo()
						// if (this.hasNextPage) {
						// 	this.message = 'more';
						// } else {
						// 	this.message = 'noMore';
						// }
					}, 500);
				}
			},
			formatDate(value) {
			  var date = new Date(value);
			  var y = date.getFullYear(),
			    m = date.getMonth() + 1,
			    d = date.getDate(),
			    h = date.getHours(),
			    i = date.getMinutes(),
			    s = date.getSeconds();
			  if (m < 10) { m = '0' + m; }
			  if (d < 10) { d = '0' + d; }
			  if (h < 10) { h = '0' + h; }
			  if (i < 10) { i = '0' + i; }
			  if (s < 10) { s = '0' + s; }
			  var t = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
			  return t;
			}
		}
	};
</script>

<style lang="less">
	.list{
		.jiuz-card{
			// border-top: 1rpx solid #efefef;
			border: 1px solid #F2F9F9;
			box-shadow: 0px 1px 17px 1px rgba(162, 215, 211, 0.16);
			border-radius: 32rpx;
			background-color: #FFFFFF;
			margin-top: 20rpx;
			margin-bottom: 40rpx;
			padding-left: 40rpx;
			padding-top: 20rpx;
			padding-bottom: 20rpx;
			.jiuz-card-row{
				width: calc(100% - 40rpx );
				display: flex;
				align-items: center;
				justify-content: flex-start;
				margin-bottom: 20rpx;
			}
			.jiuz-card-head{
				width: calc(100% - 40rpx );
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 20rpx;
			}
		}
	}
	.empty-list{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100vw;
		height: 100vh;
		background-color: #FFFFFF;
		.btn{
			width: 320rpx;
			height: 88rpx;
			line-height: 88rpx;
			text-align: center;
			color: #FFFFFF;
			background: linear-gradient(90deg, #23E0D3 0%, #00BAAD 100%);
			box-shadow: 0px 20rpx 25rpx 0px rgba(0, 186, 173, 0.4);
			border-radius: 10rpx;
		}
	}
</style>
